package com.example.nacos.consumer.controller;

import com.example.nacos.consumer.feign.OrderClientFeign;
import com.example.nacos.consumer.feign.UserFeignClient;
import com.example.nacos.consumer.model.Order;
import com.example.nacos.consumer.model.User;
import com.example.openfeign.api.ProductFeign;
import com.example.openfeign.model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName : UserClientController
 * @Description : 通过OpenFeign调用接口
 * @Author : tianshuo
 * @Date: 2021-03-17 13:44
 */
@RestController
public class UserClientController {

    @Autowired(required = false)
    private UserFeignClient userFeignClient;

    @Autowired
    private OrderClientFeign orderClientFeign;

    @Autowired
    private ProductFeign productFeign;

    @GetMapping("/userClient/{id}")
    public User user(@PathVariable("id") Integer id) {
        return userFeignClient.user(id);
    }

    @GetMapping("/orderClient/{id}")
    public Order order(@PathVariable("id") Integer id) {
        return orderClientFeign.order(id);
    }


    @GetMapping("/product/{id}")
    public Product product(@PathVariable("id") Integer id) {
        return productFeign.product(id);
    }

}

